Page({
  data: {
    score: 0,
    total: 0,
    starCount: 3,
    earnedStars: 0,
    feedbackMessage: ''
  },

  onLoad(options) {
    const score = parseInt(options.score);
    const total = parseInt(options.total);
    const percentage = (score / total) * 100;
    
    // 计算获得的星星数
    let earnedStars = 0;
    if (percentage >= 90) earnedStars = 3;
    else if (percentage >= 70) earnedStars = 2;
    else if (percentage >= 50) earnedStars = 1;

    // 根据得分设置反馈信息
    let feedbackMessage = '';
    if (percentage >= 90) {
      feedbackMessage = '太棒了！你是最棒的！';
    } else if (percentage >= 70) {
      feedbackMessage = '做得很好！继续加油！';
    } else if (percentage >= 50) {
      feedbackMessage = '还不错，再接再厉！';
    } else {
      feedbackMessage = '别灰心，下次一定会更好！';
    }

    this.setData({
      score,
      total,
      earnedStars,
      feedbackMessage
    });
  },

  retryTest() {
    wx.navigateBack({
      delta: 1
    });
  },

  goHome() {
    wx.navigateBack({
      delta: 2
    });
  }
}); 